package org.xtext.runtime.formula;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.xtext.runtime.term.Variable;
import org.xtext.runtime.util.Bindings;
import org.xtext.runtime.util.ILogicVisitor;


public class NOT implements IFormula {
	private String symbol;
	private IFormula formula;
	private Set<Variable> variables = new HashSet<Variable>();
	
	public NOT(String symbol, IFormula formula) {
		this.symbol = symbol;
		this.formula = formula;
		
		variables.addAll(formula.variables());
	}
	
	public IFormula formula() {
		return formula;
	}
	
	public String toString() {
		return symbol + formula;
	}

	@Override
	public Set<Variable> variables() {
//		return variables;
		return new HashSet<Variable>();
	}

	@Override
	public IFormula apply(Bindings bindings) {
		formula.apply(bindings);
		return this;
	}

	@Override
	public NOT copy() {
		return new NOT(symbol, formula.copy());
	}

	@Override
	public NOT copy(Map<String, Variable> vars) {
		return new NOT(symbol, formula.copy(vars));
	}

	@Override
	public boolean hasFreeVariables() {
		return formula.hasFreeVariables();
	}

	@Override
	public Object accept(ILogicVisitor visitor) {
		return visitor.visit(this);
	}

	public String sign() {
		return symbol;
	}
}
